package ajaxjs.data.service;

import java.sql.Connection;

import javax.servlet.http.HttpServletRequest;

import ajaxjs.sql.DAO;

/**
 * 杂项的基础服务
 * @author sp42
 *
 */
public class MiscService {
	public MiscService(Connection jdbcConn, HttpServletRequest request){
		this.jdbcConn = jdbcConn;
		this.request = request;
	}
	
	private Connection jdbcConn = null;
	private HttpServletRequest request = null;
	public String resetHot(String tableName) throws Exception{
		if("PUT".equals(request.getMethod())){
			DAO dao = new DAO(jdbcConn);
			dao.executeUpdate("UPDATE " + tableName + " SET isHot = 0 WHERE isHot = 1");
			
			return "复位 " + tableName + " 推荐成功！";
		}else{
			throw new Exception("HTTP 方法错误！");
		}
	}
}
